package com.roast.components;

import com.roast.domain.UserData;
import com.roast.pages.*;
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SessionAttribute;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.runtime.Component;

public class Border {

    @Parameter(required = true, defaultPrefix = "literal")
    private String pageTitle;

    @SessionAttribute
    boolean loginSA;

    @SessionAttribute
    @Property
    UserData userSA;

    @Inject
    private ComponentResources resources;

    public String getPageTitle() {
        return pageTitle;
    }

    private String getPageName() {
        Component page = resources.getContainer();
        return page.getClass().getName();
    }

    public boolean isLoginTest() {
        return getPageName().equals(Login.class.getName());
    }

    public boolean isMainTest() {
        return getPageName().equals(Main.class.getName());
    }

    public boolean isEditTest() {
        return getPageName().equals(Edit.class.getName());
    }

    public boolean isSingupTest() {
        return getPageName().equals(Singup.class.getName());
    }

    public boolean isCreateEventTest() {
        return getPageName().equals(CreateEvent.class.getName());
    }

    public boolean isUserEventsTest() {
        return getPageName().equals(UserEvents.class.getName());
    }

    public boolean isUserEventTest() {
        return getPageName().equals(UserEvent.class.getName());
    }

    public boolean isUserCommentsTest() {
        return getPageName().equals(UserComments.class.getName());
    }

    public boolean isPublicEventsTest() {
        return getPageName().equals(PublicEvents.class.getName());
    }

    public boolean isPublicEventTest() {
        return getPageName().equals(PublicEvent.class.getName());
    }

    public boolean isPublicCommentsTest() {
        return getPageName().equals(PublicComments.class.getName());
    }

    public boolean isUserLoginTest() {
        return loginSA;
    }

    public boolean isUserNotLoginTest() {
        return !loginSA;
    }
}
